<template>
  <el-dialog title="回答问题" :visible="visible" @close="handleClose">
    <el-form label-width="90px">
      <el-form-item label="问题名称">
        <span>
          {{form.questionName}}
        </span>
        <el-input v-model="form.courseName"></el-input>
      </el-form-item>
      <el-form-item label="问题回答">
        <el-input v-model="form.questionAnswer"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="onSubmit">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    props: ['visible', 'data'],
    data () {
      return {
        form: {}
      }
    },
    watch: {
      data(val) {
        this.form = val;
      }
    },
    methods: {
      handleClose() {
        this.$emit('update:visible', false)
      },
      onSubmit() {
        this.$api.qa.answer(this.form).then(res => {
          if(res.success) {
            this.$message.success('操作成功')
            this.$emit('update:visible', false)
          }
        })
      }
    }
  }
</script>
